// pages/analysis/index.js
import config from '../../config/index.js'
import wxRequest from '../../utils/wxRequest.js'
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    domain: '', //域名
    type: '', //类型 ype==today 今天 或者type == yesterday 昨天
    lists: [] //对比分析
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    console.log(options)
    var that = this;
    that.setData({
      type: options.type,
      domain: options.domain
    })
    //设置标题
    const title = options.type == 'today' ? '今天对比分析' : '昨天对比分析';
    wx.setNavigationBarTitle({
      title,
    })

    that.getList();
  },
  //获取对比分析数据
  getList() {
    var that = this;
    var map = {
      'domain': that.data.domain,
      'type': that.data.type,
    }
    wxRequest.getRequest('/toolkit/copy/houre_list', map).then(res => {
      console.log(res)
      that.setData({
        lists: res.data
      })
    }).catch(error => {})
  }
  
})